package com.enation.app.javashop.api.client;

import com.enation.app.javashop.model.member.dos.MemberCollectionGoods;
import com.enation.app.javashop.service.member.MemberCollectionGoodsManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 会员收藏商品相关api
 *
 * @author zh
 * @version v7.0
 * @date 18/7/30 下午8:10
 * @since v7.0
 */
@Api(description = "会员收藏商品api")
@RestController
@RequestMapping("/client/members/collection-goods")
@Validated
@ApiIgnore
public class MembeCollectionGoodsClientController {

    @Autowired
    private MemberCollectionGoodsManager memberCollectionGoodsManager;

    @ApiOperation(value = "获取会员收藏商品数", response = MemberCollectionGoods.class)
    @GetMapping("/{goods_id}")
    @ApiImplicitParam(name = "goods_id", value = "商品id", required = true, dataType = "int", paramType = "path")
    public Integer getMemberAddress(@ApiIgnore @PathVariable("goods_id") Long goodsId) {
        return memberCollectionGoodsManager.getGoodsCollectCount(goodsId);
    }

    @RequestMapping(value = "/{goods_id}/update-goods-name", method = RequestMethod.POST)
    public void updateGoodsName(@PathVariable("goods_id")Long goodsId,@RequestParam("goods_name") String goodsName){

        memberCollectionGoodsManager.updateGoodsName(goodsId, goodsName);
    }


}
